return reply.value(headerName).toString().toLatin1();
}
-constexpr auto batchSize = 100;
constexpr auto parallelJobsMaximumCount = 1;
}
BulkPropagatorJob::BulkPropagatorJob(OwncloudPropagator *propagator, const std::deque<SyncFileItemPtr> &items)
: PropagatorJob(propagator)
, _items(items)
- , _currentBatchSize(batchSize)
+ , _currentBatchSize(_items.size())
{
- _filesToUpload.reserve(batchSize);
- _pendingChecksumFiles.reserve(batchSize);
+ _filesToUpload.reserve(_items.size());
+ _pendingChecksumFiles.reserve(_items.size());
}
bool BulkPropagatorJob::scheduleSelfOrChild()
_state = Running;
- for(auto i = 0; i < _currentBatchSize && !_items.empty(); ++i) {
+ qCDebug(lcBulkPropagatorJob()) << "max chunk size" << PropagatorJob::propagator()->syncOptions().maxChunkSize();
+
+ for(auto batchDataSize = 0; batchDataSize <= PropagatorJob::propagator()->syncOptions().maxChunkSize() && !_items.empty(); ) {
const auto currentItem = _items.front();
_items.pop_front();
_pendingChecksumFiles.insert(currentItem->_file);
+ batchDataSize += currentItem->_size;
+
QMetaObject::invokeMethod(this, [this, currentItem] {
UploadFileInfo fileToUpload;
fileToUpload._file = currentItem->_file;
}
// change batch size before trying it again
- const auto halfBatchSize = batchSize / 2;
+ const auto halfBatchSize = static_cast<int>(_items.size() / 2);
// we already tried to upload with half of the batch size
if(_currentBatchSize == halfBatchSize) {
qint64 ConfigFile::maxChunkSize() const
{
QSettings settings(configFile(), QSettings::IniFormat);
- return settings.value(QLatin1String(maxChunkSizeC), 5LL * 1000LL * 1000LL * 1000LL).toLongLong(); // default to 5000 MB
+ return settings.value(QLatin1String(maxChunkSizeC), 100LL * 1024LL * 1024LL).toLongLong(); // default to 100 MiB
}
qint64 ConfigFile::minChunkSize() const
{
QSettings settings(configFile(), QSettings::IniFormat);
- return settings.value(QLatin1String(minChunkSizeC), 5LL * 1000LL * 1000LL).toLongLong(); // default to 5 MB
+ return settings.value(QLatin1String(minChunkSizeC), 5LL * 1024LL * 1024LL).toLongLong(); // default to 5 MiB
}
chrono::milliseconds ConfigFile::targetChunkUploadDuration() const